package br.com.project.persistence;


public class DataHelper {
//	private static final String DATABASE_NAME = "bizz.db";
//	private static final int DATABASE_VERSION = 1;
//
//	private Context context;
//	private SQLiteDatabase db;
//
//	private SQLiteStatement insertStmt;
////	private static final String INSERT = "insert into " + TABLE_NAME + "(name) values (?)";
//	
//
//	/* Tables */
//	private static final String SIMULATION_TABLE = "Simulation";
//	private static final String QUESTION_TABLE = "Question";
//	private static final String ANSWER_TABLE = "Answer";
//	private static final String QUESTION_ANSWER_TABLE = "Question_Answer";
//	private static final String SIMULATION_QUESTION_TABLE = "Simulation_Question";
//	
//	/* Colunas da tabela Answer */
//	private static final String COL_ANSWER_ID = "id";
//	private static final String COL_ANSWER = "answer";
//	private static final String COL_RIGHT = "right";
//	
//	/* Colunas da tabela Question */
//	private static final String COL_QUESTION_ID = "id";
//	private static final String COL_QUESTION = "question";
//	
//	/* Colunas da tabela Question_Answer */
//	private static final String COL_ANSWER_QA_ID = "id_answer";
//	private static final String COL_QUESTION_QA_ID = "id_question";
//	
//	/* Colunas da tabela Simulation */
//	private static final String COL_SIMULATION_ID = "id";
//	private static final String COL_TITLE = "title";
//	private static final String COL_DESCRIPTION = "description";
//	
//	/* Colunas da tabela Simulation_Question */
//	private static final String COL_SIMULATION_SQ_ID = "id_simulation";
//	private static final String COL_QUESTION_SQ_ID = "id_question";
//	
//	private static final String INSERT_SIMULATION = "INSERT INTO " + SIMULATION_TABLE + " (" + COL_SIMULATION_ID + ", "+COL_TITLE+", "+COL_DESCRIPTION+") VALUES (?,?,?);";
//	private static final String INSERT_QUESTION = "INSERT INTO " + QUESTION_TABLE + " (" + COL_QUESTION_ID + ", " + COL_QUESTION + ") VALUES (?,?);";
//	private static final String INSERT_SIMULATION_QUESTION = "INSERT INTO " + SIMULATION_QUESTION_TABLE + " (" + COL_SIMULATION_SQ_ID + ", " + COL_QUESTION_SQ_ID + ") VALUES (?,?);";
//	private static final String INSERT_ANSWER = "INSERT INTO " + ANSWER_TABLE + " (" + COL_ANSWER_ID + ", " + COL_ANSWER + ", " + COL_RIGHT + ") VALUES (?,?,?);";
//	private static final String INSERT_QUESTION_ANSWER = "INSERT INTO " + QUESTION_ANSWER_TABLE + " (" + COL_QUESTION_QA_ID + ", " + COL_ANSWER_QA_ID + ") VALUES (?,?);";
//
//	public DataHelper(Context context) {
//		this.context = context;
//		OpenHelper openHelper = new OpenHelper(this.context);
//		this.db = openHelper.getWritableDatabase();
//	}
//
//	public long insert(Simulation simulation) {
//		
//		int simulationID = simulation.getId();
//		List<Question> questions = simulation.getQuestions();
//		
//		this.insertStmt = this.db.compileStatement(INSERT_SIMULATION);
//		this.insertStmt.bindString(1, String.valueOf(simulationID));
//		this.insertStmt.bindString(2, simulation.getTitle());
//		this.insertStmt.bindString(3, simulation.getDescription());
//		
//		this.insertStmt.executeInsert();
//		
//		for(Question question: questions){
//			
//		}
//		
//		
//		return this.insertStmt.executeInsert();
//	}
//
//	public void deleteAll() {
//		this.db.delete(SIMULATION_TABLE, null, null);
//	}
//
//	public List<String> selectAll() {
//		List<String> list = new ArrayList<String>();
//		Cursor cursor = this.db.query(SIMULATION_TABLE, new String[] { "title" },
//				null, null, null, null, "title desc");
//		if (cursor.moveToFirst()) {
//			do {
//				list.add(cursor.getString(0));
//			} while (cursor.moveToNext());
//		}
//		if (cursor != null && !cursor.isClosed()) {
//			cursor.close();
//		}
//		return list;
//	}
//
//	private static class OpenHelper extends SQLiteOpenHelper {
//
//		OpenHelper(Context context) {
//			super(context, DATABASE_NAME, null, DATABASE_VERSION);
//		}
//
//		@Override
//	    public void onCreate(SQLiteDatabase db) {
//			db.execSQL("CREATE TABLE IF NOT EXISTS " + ANSWER_TABLE 
//					+ " (" 
//						+ COL_ANSWER_ID + " INTEGER PRIMARY KEY, " 
//						+ COL_ANSWER + " TEXT, "
//						+ COL_RIGHT +" BOOLEAN" 
//					+ ")");
//			
//			db.execSQL("CREATE TABLE IF NOT EXISTS " + QUESTION_TABLE 
//					+ " (" 
//						+ COL_QUESTION_ID + " INTEGER PRIMARY KEY, " 
//						+ COL_QUESTION + " TEXT" 
//					+ ")");
//			
//			db.execSQL("CREATE TABLE IF NOT EXISTS " + SIMULATION_TABLE 
//					+ " (" 
//						+ COL_SIMULATION_ID + " INTEGER PRIMARY KEY, " 
//						+ COL_TITLE + " TEXT, "
//						+ COL_DESCRIPTION +" TEXT" 
//					+ ")");
//			
//			db.execSQL("CREATE TABLE IF NOT EXISTS " + QUESTION_ANSWER_TABLE 
//					+ " (" 
//						+ COL_QUESTION_QA_ID + " INTEGER NOT NULL, " 
//						+ COL_ANSWER_QA_ID + " INTEGER NOT NULL, "
//						+ "PRIMARY KEY (" + COL_QUESTION_QA_ID + ", " + COL_ANSWER_QA_ID + "), "
//						+ "FOREIGN KEY (" + COL_QUESTION_QA_ID + ") REFERENCES " + QUESTION_TABLE + " (" + COL_QUESTION_ID + "), "
//						+ "FOREIGN KEY (" + COL_ANSWER_QA_ID + ") REFERENCES " + ANSWER_TABLE + " (" + COL_ANSWER_ID + ")"
//					+ ")");
//			
//			db.execSQL("CREATE TABLE IF NOT EXISTS " + SIMULATION_QUESTION_TABLE 
//					+ " (" 
//						+ COL_SIMULATION_SQ_ID + " INTEGER NOT NULL, " 
//						+ COL_QUESTION_SQ_ID + " INTEGER NOT NULL, "
//						+ "PRIMARY KEY (" + COL_SIMULATION_SQ_ID + ", " + COL_QUESTION_SQ_ID + "), "
//						+ "FOREIGN KEY (" + COL_SIMULATION_SQ_ID + ") REFERENCES " + SIMULATION_TABLE + " (" + COL_SIMULATION_ID + "), "
//						+ "FOREIGN KEY (" + COL_QUESTION_SQ_ID + ") REFERENCES " + QUESTION_TABLE + " (" + COL_QUESTION_ID + ")"
//					+ ")");
//	      }
//
//		@Override
//		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//			Log.w("Example",
//					"Upgrading database, this will drop tables and recreate.");
//			db.execSQL("DROP TABLE IF EXISTS " + SIMULATION_QUESTION_TABLE);
//			db.execSQL("DROP TABLE IF EXISTS " + QUESTION_ANSWER_TABLE);
//			db.execSQL("DROP TABLE IF EXISTS " + ANSWER_TABLE);
//			db.execSQL("DROP TABLE IF EXISTS " + QUESTION_TABLE);
//			db.execSQL("DROP TABLE IF EXISTS " + SIMULATION_TABLE);
//			onCreate(db);
//		}
//	}
}
